﻿#pragma once
#include"Common.h"
#include"PageCache.h"

// 单例模式 全局唯一  懒汉模式与饿汉模式不同
class CentralCache
{
public:
	static CentralCache* GetInstence()
	{
		return &_owner;
	}

	// 获取⼀个⾮空的
	span* GetOneSpan(SpanList& list, size_t byte_size);

	// 获得定长内存块链表
	size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);

	// 将⼀定数量的对象释放到span
	void ReleaseListToSpans(void* start, size_t size);

private:
	CentralCache() {};
	CentralCache(CentralCache &) = delete;
	CentralCache& operator=(const CentralCache&) = delete;


	static CentralCache _owner;
	SpanList _spanLists[NFREELISTS];
};


